unit uCreateCodedEntity;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons;

type
  TfmCreateCodedEntity = class(TForm)
    lbCode: TLabel;
    Label2: TLabel;
    edName: TEdit;
    edCode: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
  private
    { Private declarations }
    procedure ClearFields;
  public
    { Public declarations }
    Code : string;
    Name : string;

    function Execute(WindowCaption : string; isCodeFieldNeeded : boolean):boolean;
  end;

var
  fmCreateCodedEntity: TfmCreateCodedEntity;

implementation

{$R *.dfm}

procedure TfmCreateCodedEntity.ClearFields;
begin
  edName.Text := '';
  edCode.Text := '';
end;

function TfmCreateCodedEntity.Execute(WindowCaption : string; isCodeFieldNeeded : boolean):boolean;
begin
  result := false;

  Caption := WindowCaption;
  if isCodeFieldNeeded then
  begin
    edCode.Visible := true;
    lbCode.Visible := true;
    Height := 137;
  end
  else
  begin
    edCode.Visible := false;
    lbCode.Visible := false;
    Height := 108;
  end;

  ClearFields;

  if (ShowModal = mrOk) then
  begin
    Name := edName.Text;
    Code := edCode.Text;
    
    result := true;
  end;
end;
end.
